package com.ruoyi.web.controller.safety;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.safety.domain.PointTypeDict;
import com.ruoyi.safety.service.IPointTypeDictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测点报警/异常类型字典Controller
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/safety/pointTypeDict")
public class PointTypeDictController extends BaseController
{
    @Autowired
    private IPointTypeDictService pointTypeDictService;

    /**
     * 查询测点报警/异常类型字典列表
     */
    //@PreAuthorize("@ss.hasPermi('safety:dict:list')")
    @GetMapping("/list")
    @ApiOperation("测点报警/异常类型")
    public TableDataInfo list(PointTypeDict pointTypeDict)
    {
        startPage();
        List<PointTypeDict> list = pointTypeDictService.selectPointTypeDictList(pointTypeDict);
        return getDataTable(list);
    }

    /**
     * 导出测点报警/异常类型字典列表
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:export')")
    @Log(title = "测点报警/异常类型字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PointTypeDict pointTypeDict)
    {
        List<PointTypeDict> list = pointTypeDictService.selectPointTypeDictList(pointTypeDict);
        ExcelUtil<PointTypeDict> util = new ExcelUtil<PointTypeDict>(PointTypeDict.class);
        util.exportExcel(response, list, "测点报警/异常类型字典数据");
    }

    /**
     * 获取测点报警/异常类型字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:query')")
    @GetMapping(value = "/{pointId}")
    public AjaxResult getInfo(@PathVariable("pointId") String pointId)
    {
        return success(pointTypeDictService.selectPointTypeDictByPointId(pointId));
    }

    /**
     * 新增测点报警/异常类型字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:add')")
    @Log(title = "测点报警/异常类型字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PointTypeDict pointTypeDict)
    {
        return toAjax(pointTypeDictService.insertPointTypeDict(pointTypeDict));
    }

    /**
     * 修改测点报警/异常类型字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:edit')")
    @Log(title = "测点报警/异常类型字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PointTypeDict pointTypeDict)
    {
        return toAjax(pointTypeDictService.updatePointTypeDict(pointTypeDict));
    }

    /**
     * 删除测点报警/异常类型字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:remove')")
    @Log(title = "测点报警/异常类型字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pointIds}")
    public AjaxResult remove(@PathVariable String[] pointIds)
    {
        return toAjax(pointTypeDictService.deletePointTypeDictByPointIds(pointIds));
    }
}
